#region License

// Copyright (c) 2013, ClearCanvas Inc.
// All rights reserved.
// http://www.clearcanvas.ca
//
// This file is part of the ClearCanvas RIS/PACS open source project.
//
// The ClearCanvas RIS/PACS open source project is free software: you can
// redistribute it and/or modify it under the terms of the GNU General Public
// License as published by the Free Software Foundation, either version 3 of the
// License, or (at your option) any later version.
//
// The ClearCanvas RIS/PACS open source project is distributed in the hope that it
// will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General
// Public License for more details.
//
// You should have received a copy of the GNU General Public License along with
// the ClearCanvas RIS/PACS open source project.  If not, see
// <http://www.gnu.org/licenses/>.

#endregion

// This file is auto-generated by the ClearCanvas.Model.SqlServer.CodeGenerator project.

namespace ClearCanvas.ImageServer.Model
{
    using System;
    using System.Xml;
    using ClearCanvas.Enterprise.Core;
    using ClearCanvas.ImageServer.Enterprise;
    using ClearCanvas.ImageServer.Enterprise.Command;
    using ClearCanvas.ImageServer.Model.EntityBrokers;

    [Serializable]
    public partial class ServerPartition: ServerEntity
    {
        #region Constructors
        public ServerPartition():base("ServerPartition")
        {}
        public ServerPartition(
             Boolean _enabled_
            ,String _description_
            ,String _aeTitle_
            ,Int32 _port_
            ,String _partitionFolder_
            ,Boolean _acceptAnyDevice_
            ,Boolean _auditDeleteStudy_
            ,Boolean _autoInsertDevice_
            ,Int32 _defaultRemotePort_
            ,Int32 _studyCount_
            ,DuplicateSopPolicyEnum _duplicateSopPolicyEnum_
            ,Boolean _matchAccessionNumber_
            ,Boolean _matchIssuerOfPatientId_
            ,Boolean _matchPatientId_
            ,Boolean _matchPatientsBirthDate_
            ,Boolean _matchPatientsName_
            ,Boolean _matchPatientsSex_
            ,Boolean _acceptLatestReport_
            ,ServerPartitionTypeEnum _serverPartitionTypeEnum_
            ):base("ServerPartition")
        {
            Enabled = _enabled_;
            Description = _description_;
            AeTitle = _aeTitle_;
            Port = _port_;
            PartitionFolder = _partitionFolder_;
            AcceptAnyDevice = _acceptAnyDevice_;
            AuditDeleteStudy = _auditDeleteStudy_;
            AutoInsertDevice = _autoInsertDevice_;
            DefaultRemotePort = _defaultRemotePort_;
            StudyCount = _studyCount_;
            DuplicateSopPolicyEnum = _duplicateSopPolicyEnum_;
            MatchAccessionNumber = _matchAccessionNumber_;
            MatchIssuerOfPatientId = _matchIssuerOfPatientId_;
            MatchPatientId = _matchPatientId_;
            MatchPatientsBirthDate = _matchPatientsBirthDate_;
            MatchPatientsName = _matchPatientsName_;
            MatchPatientsSex = _matchPatientsSex_;
            AcceptLatestReport = _acceptLatestReport_;
            ServerPartitionTypeEnum = _serverPartitionTypeEnum_;
        }
        #endregion

        #region Public Properties
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="Enabled")]
        public Boolean Enabled
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="Description")]
        public String Description
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="AeTitle")]
        public String AeTitle
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="Port")]
        public Int32 Port
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="PartitionFolder")]
        public String PartitionFolder
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="AcceptAnyDevice")]
        public Boolean AcceptAnyDevice
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="AuditDeleteStudy")]
        public Boolean AuditDeleteStudy
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="AutoInsertDevice")]
        public Boolean AutoInsertDevice
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="DefaultRemotePort")]
        public Int32 DefaultRemotePort
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="StudyCount")]
        public Int32 StudyCount
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="DuplicateSopPolicyEnum")]
        public DuplicateSopPolicyEnum DuplicateSopPolicyEnum
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="MatchAccessionNumber")]
        public Boolean MatchAccessionNumber
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="MatchIssuerOfPatientId")]
        public Boolean MatchIssuerOfPatientId
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="MatchPatientId")]
        public Boolean MatchPatientId
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="MatchPatientsBirthDate")]
        public Boolean MatchPatientsBirthDate
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="MatchPatientsName")]
        public Boolean MatchPatientsName
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="MatchPatientsSex")]
        public Boolean MatchPatientsSex
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="AcceptLatestReport")]
        public Boolean AcceptLatestReport
        { get; set; }
        [EntityFieldDatabaseMappingAttribute(TableName="ServerPartition", ColumnName="ServerPartitionTypeEnum")]
        public ServerPartitionTypeEnum ServerPartitionTypeEnum
        { get; set; }
        #endregion

        #region Static Methods
        static public ServerPartition Load(ServerEntityKey key)
        {
            using (var context = new ServerExecutionContext())
            {
                return Load(context.ReadContext, key);
            }
        }
        static public ServerPartition Load(IPersistenceContext read, ServerEntityKey key)
        {
            var broker = read.GetBroker<IServerPartitionEntityBroker>();
            ServerPartition theObject = broker.Load(key);
            return theObject;
        }
        static public ServerPartition Insert(ServerPartition entity)
        {
            using (var update = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                ServerPartition newEntity = Insert(update, entity);
                update.Commit();
                return newEntity;
            }
        }
        static public ServerPartition Insert(IUpdateContext update, ServerPartition entity)
        {
            var broker = update.GetBroker<IServerPartitionEntityBroker>();
            var updateColumns = new ServerPartitionUpdateColumns();
            updateColumns.Enabled = entity.Enabled;
            updateColumns.Description = entity.Description;
            updateColumns.AeTitle = entity.AeTitle;
            updateColumns.Port = entity.Port;
            updateColumns.PartitionFolder = entity.PartitionFolder;
            updateColumns.AcceptAnyDevice = entity.AcceptAnyDevice;
            updateColumns.AuditDeleteStudy = entity.AuditDeleteStudy;
            updateColumns.AutoInsertDevice = entity.AutoInsertDevice;
            updateColumns.DefaultRemotePort = entity.DefaultRemotePort;
            updateColumns.StudyCount = entity.StudyCount;
            updateColumns.DuplicateSopPolicyEnum = entity.DuplicateSopPolicyEnum;
            updateColumns.MatchAccessionNumber = entity.MatchAccessionNumber;
            updateColumns.MatchIssuerOfPatientId = entity.MatchIssuerOfPatientId;
            updateColumns.MatchPatientId = entity.MatchPatientId;
            updateColumns.MatchPatientsBirthDate = entity.MatchPatientsBirthDate;
            updateColumns.MatchPatientsName = entity.MatchPatientsName;
            updateColumns.MatchPatientsSex = entity.MatchPatientsSex;
            updateColumns.AcceptLatestReport = entity.AcceptLatestReport;
            updateColumns.ServerPartitionTypeEnum = entity.ServerPartitionTypeEnum;
            ServerPartition newEntity = broker.Insert(updateColumns);
            return newEntity;
        }
        #endregion
    }
}
